import * as dayjs from 'dayjs'
import store from '@/store'
export default {
  install: function(Vue) {
    // console.log(Vue, 999)
    Vue.directive('errorImg', {
      inserted: function(el, obj) {
        el.onerror = function() {
        //   console.log(el, obj.value, 111)
          el.src = obj.value
        }
      }
    })
    Vue.directive('allow', {
      inserted: function(el, binding) {
        var pints = store.state.user.userInfo.roles.points
        var flag = pints.includes(binding.value)
        if (!flag) {
          el.parentNode.removeChild(el)
        }
      }
    })
    Vue.filter('format', (msg, str) => {
      return dayjs(msg).format(str)
    })
  }
}
